home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 18 / develop 18 code / OSA Sample / Sources / WindowObj.h < prev   
Encoding:
C/C++ Source or Header  |  1994-02-04  |  5.7 KB  |  234 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        WindowObj.h
  3.  
  4.     Contains:    Windows for a simple Scriptable application.
  5.  
  6.     Developed by:    
  7.         
  8.         Paul G Smith (commstalk hq & Full Moon Software, Inc)
  9.         
  10.         you can leave messages at (UK): 0727 844232; (US): 408 253 7199
  11.         BUT I prefer to be contacted by e-mail
  12.         AppleLink:     SMITH.PG
  13.         Internet:     SMITH.PG@applelink.apple.com
  14.         
  15.         "SimpliFace" Sample code to accompany develop article
  16.         on techniques for embedding scripts in applications.
  17.  
  18. */
  19.  
  20. #ifndef __WINDOWOBJ__
  21. #define __WINDOWOBJ__
  22.  
  23. #ifndef __SCRIPTOBJECTS__
  24. #include "ScriptableObjects.h"
  25. #endif
  26.  
  27. #ifndef __PASCALSTRING__
  28. #include "PascalString.h"
  29. #endif
  30.  
  31. #ifndef __CONTROLS__
  32. #include "Controls.h"
  33. #endif
  34.  
  35.  
  36. /**********************************************************************
  37. ** class TWindowObj
  38. ***********************************************************************/
  39.  
  40. class TWindowObj : public TScriptableObject {
  41. public:
  42.                                 TWindowObj();
  43.                                 TWindowObj(const AEDesc *theData);
  44.     virtual                        ~TWindowObj();
  45.  
  46.     virtual    void    ActivateWindow(Boolean isActivating);
  47.  
  48.     virtual    void    UpdateWindow(void);
  49.  
  50.     virtual    void    DrawAllElements(DescType desiredClass);
  51.  
  52.     virtual    void    DrawWindow(void);
  53.  
  54.     virtual    TScriptableObject*    FindElement(Point& thePt, DescType desiredClass);
  55.     
  56.     virtual  OSErr OpenObject  (void);
  57.                                         
  58.     virtual  OSErr CloseObject  (void);
  59.                                         
  60.     
  61.     virtual  OSErr CountElements (DescType desiredClass,
  62.                                         long *result);
  63.                                         
  64.     virtual  OSErr ResolveContainer    (TScriptableObject **theContainerObj);
  65.  
  66.     virtual  OSErr ResolveElementByName(DescType desiredClass,
  67.                                         CStr255& nameStr,
  68.                                         TScriptableObject **theResultObj);
  69.                                         
  70.     virtual  OSErr ResolveElementByIndex(DescType desiredClass,
  71.                                         short theIndex,
  72.                                         TScriptableObject **theResultObj);
  73.  
  74.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  75.                                                 
  76.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  77.                                         
  78.     virtual  OSErr GetObjectSpecifier  (AEDesc *result);
  79.                                         
  80.     virtual  OSErr GetTargetObjectSpecifier  (EventRecord& theEvent, AEDesc *result);
  81.  
  82.     virtual     OSErr CreateNewElement    (DescType desiredClass,
  83.                                         DescType position,
  84.                                         AEDesc *theData,
  85.                                         AERecord *theProperties,
  86.                                         TScriptableObject *theContainerObj,
  87.                                         TScriptableObject **theNewObj);
  88.  
  89.             void    GetName(CStr255& theName)     { theName = fName; };
  90.  
  91.             WindowPtr    GetWindowPtr(void)     { return fWindowPtr; };
  92.             
  93. private:
  94.             void    InitFields(void);
  95.             
  96. protected:
  97.     Boolean            fInitialized;
  98.     Rect            fBounds;
  99.     Boolean            fHasCloseBox;
  100.     Boolean            fHasTitleBar;
  101.     Boolean            fIsModal;
  102.     Boolean            fIsResizable;
  103.     Boolean            fIsZoomable;
  104.     Boolean            fIsZoomed;
  105.     CStr255            fName;
  106.     Boolean            fShouldBeVisible;
  107.     Boolean            fHasBeenCreated;
  108.     short            fWindowDefProc;
  109.     WindowPtr        fWindowPtr;
  110.     TListOfLongs    fButtonElems;    // list of *TInterfaceObj
  111.     TListOfLongs    fFieldElems;    // list of *TInterfaceObj
  112. };
  113.  
  114.  
  115. //
  116. // interface classes:
  117. //
  118. //        TInterfaceObj (defines all common properties of descendants)
  119. //              |
  120. //              |
  121. //        ______|______
  122. //        |            |
  123. //    TButtonObj    TLabelObj
  124. //
  125.  
  126.  
  127. /**********************************************************************
  128. ** class TInterfaceObj
  129. ***********************************************************************/
  130.  
  131. class TInterfaceObj : public TScriptableObject {
  132. public:
  133.                                 TInterfaceObj(TWindowObj* container);
  134.                                 TInterfaceObj(TWindowObj* container,
  135.                                                 const AEDesc *theData);
  136.     virtual                        ~TInterfaceObj();
  137.  
  138.     virtual    void    DrawObject (void);
  139.  
  140.     virtual    void    ForceRedrawObject (Boolean drawNow);
  141.  
  142.     virtual  OSErr ResolveContainer    (TScriptableObject **theContainerObj);
  143.  
  144.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  145.                                                 
  146.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  147.  
  148.                                         
  149.     virtual  OSErr GetObjectSpecifier  (AEDesc *result);
  150.  
  151.     virtual  DescType    GetClass(void);
  152.  
  153.             void    GetName(CStr255& theName)     { theName = fName; };
  154.  
  155.             void    GetBounds(Rect& theBounds)     { theBounds = fBounds; };
  156.             
  157. protected:
  158.     virtual  void    InitFields(void);
  159.             
  160.     TWindowObj*        fContainer;
  161.     Boolean            fInitialized;
  162.     Rect            fBounds;
  163.     CStr255            fName;
  164.     CStr255            fFontName;
  165.     short            fFontSize;
  166.     short            fFontStyle;
  167.     RGBColor        fFgColor;
  168. };
  169.  
  170.  
  171.  
  172.  
  173. /**********************************************************************
  174. ** class TButtonObj
  175. ***********************************************************************/
  176.  
  177. class TButtonObj : public TInterfaceObj {
  178. public:
  179.                                 TButtonObj(TWindowObj* container);
  180.                                 TButtonObj(TWindowObj* container,
  181.                                             const AEDesc *theData);
  182.     virtual                        ~TButtonObj();
  183.  
  184.     virtual    void    DrawObject (void);
  185.  
  186.     virtual    void    ForceRedrawObject (Boolean drawNow);
  187.  
  188.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  189.                                                 
  190.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  191.  
  192.     virtual  DescType    GetClass(void);
  193.  
  194. protected:
  195.     virtual  void    InitFields(void);
  196.             
  197.     DescType        fButtonKind;
  198.     ControlHandle    fControlH;
  199. };
  200.  
  201.  
  202.  
  203. /**********************************************************************
  204. ** class TLabelObj
  205. ***********************************************************************/
  206.  
  207. class TLabelObj : public TInterfaceObj {
  208. public:
  209.                                 TLabelObj(TWindowObj* container);
  210.                                 TLabelObj(TWindowObj* container,
  211.                                             const AEDesc *theData);
  212.     virtual                        ~TLabelObj();
  213.  
  214.     virtual    void    DrawObject (void);
  215.  
  216.     virtual    void    ForceRedrawObject (Boolean drawNow);
  217.  
  218.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  219.                                                 
  220.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  221.  
  222.     virtual  DescType    GetClass(void);
  223.     
  224. protected:
  225.     virtual  void    InitFields(void);
  226.     
  227.     Handle        fContents;    // contents of field, raw text
  228. };
  229.  
  230.  
  231.  
  232.  
  233. #endif
  234.